package com.ynt.pay.user.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ynt.pay.user.api.dto.UserListDto;
import com.ynt.pay.user.domain.User;
import com.ynt.pay.user.mapper.UserMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserServiceImpl implements com.ynt.pay.user.service.UserService {

    @Autowired
    UserMapper userMapper;

    @Override
    public List<UserListDto> list() {
        List<User> users = userMapper.selectList(new QueryWrapper<>());
        List<UserListDto> list = new ArrayList<>();
        for (User user : users) {
            UserListDto dto = new UserListDto();
            BeanUtils.copyProperties(user, dto);
            list.add(dto);
        }
        return list;
    }
}
